Installing an Ubuntu Development Support Server
This topic documents the steps to install development support applications on Ubuntu Linux on an x86 server. __TOC__ Prerequisites These instructions assume that you are installing to a server with the following configuration: * Ubuntu 9.10 Server with the following package tasks installed: ** LAMP Server ** OpenSSH Server Refer to the Ubuntu Server Guide for detailed instructions. These instructions assume that any firewalls present in the network are configured to permit the following access: * The server will need to connect to the Internet NTP service pools via TCP on port 123. These instructions assume that you are logged on to a Linux shell prompt as the administrative user established during the Ubuntu installation. Please ensure that you have satisfied all these requirements before proceeding. Ubuntu Server Configuration Upgrade Ubuntu Packages Before installing the application packages, it is important to upgrade the base Ubuntu Server packages to the latest versions from the official repositories. * Update the package index: sudo apt-get update * Upgrade packages: sudo apt-get upgrade Set Time Zone and Set Hardware Clock to UTC Development support applications such as version management and continuous integration systems depend on file timestamps for proper operation. For this reason, it is important that all development support servers in a network have coordinated hardware clocks and a common time zone setting. * Ensure that the hardware clock is set to UTC: sudo hwclock --show --utc If the hardware clock is properly set to UTC, the time shown should be the correct local time. If the hardware clock is not set to UTC, the time will be incorrect by the offset between UTC and local time (-7 hours). * Check the date: date * If the date is not correct, reset it. Note: The specified date should be in local time: sudo date -s "Wed Jan 1 00:00:00 MST 2010" * Ensure that the hardware clock is set to UTC: sudo hwclock --show --utc If the hardware clock is properly set to UTC, the time shown should be the correct local time. If the hardware clock is not set to UTC, the time will be incorrect by the offset between UTC and local time (-7 hours). * Synchronize the hardware clock to the system clock: sudo hwclock --systohc --utc Install, Configure and Test NTP To ensure that the server clock stays accurate, the NTP daemon should be installed and configured to use several time servers. * Install the ntp package: sudo apt-get install ntp * Edit the /etc/ntp.conf file to add the following entries after the server ntp.ubuntu.com entry: server 0.us.pool.ntp.org server 1.us.pool.ntp.org server 2.us.pool.ntp.org * Restart the NTP daemon: sudo /etc/init.d/ntp restart * Check whether NTP is able to contact the server pool: sudo ntpq -p * Check the time difference between the local system and the remote time server: sudo ntpdate -d ntp.ubuntu.com Install and Configure Postfix Development support applications often use email notification as part of workflow. The Ubuntu Mail Server package task sets up a full-blown Internet mail server. To avoid the complexities of this, it is best to install the Postfix Mail Transfer Agent separately and configure it as a satellite system relaying to your ISP's SMTP host. * Install the postfix package sudo apt-get install postfix * In the Postfix installation, simply accept the defaults. Actual configuration will be performed in the next section. * Configure the postfix package sudo dpkg-reconfigure postfix * In the Postfix configuration, accept the defaults with the following exceptions: ** General type of mail configuration: Satellite system ** System mail name: maildomain (example: "mydomain.net") ** SMTP relay host: relayhost (example: "mail.mydomain.net") ** Root and postmaster mail recipient: adminuser (example: "admin") ** Other destinations to accept mail for: destinationlist (example: "myhost.SME, localhost.SME, localhost" Install ZIP To enable use of archive files in the popular ZIP format, install the zip package. * Install the zip package: sudo apt-get install zip Application Configuration Install and Configure Subversion Subversion is an open-source version control system. The following instructions install the Subversion repository and configure the Apache 2 HTTP server to permit access to the repository via the WebDAV protocol. * Install the subversion package: sudo apt-get install subversion libapache2-svn * Create an apache2 configuration file /etc/subversion/apache.conf with the following contents: DAV svn SVNParentPath /var/lib/svn AuthType Basic AuthName "Subversion repository" AuthUserFile /etc/subversion/passwd Require valid-user * Add the configuration file to the Apache 2 server configuration sudo ln -sn /etc/subversion/apache.conf /etc/apache2/conf.d/subversion.conf * Create an initial repository and user file. Note: Replace myproject with the project name sudo mkdir /var/lib/svn sudo chown -R www-data:www-data /var/lib/svn sudo htpasswd -c /etc/subversion/passwd svn sudo chown www-data:www-data /etc/subversion/passwd sudo su www-data svnadmin create /var/lib/svn/myproject * Restart the Apache 2 server sudo /etc/init.d/apache2 restart Install and Configure MediaWiki MediaWiki is an web based Wiki useful for collaboration among members of a development team. The following instructions install MediaWiki and configure it for this use. * Install the mediawiki package: sudo apt-get install mediawiki php5-gd * Edit the /etc/mediawiki/apache.conf file (linked from /etc/apache2/conf.d/mediawiki.conf) to uncomment the following line to enable access to the MediaWiki application: Alias /mediawiki /var/lib/mediawiki * Edit the /etc/mediawiki/apache.conf file to append the following lines at the end of the file to permit file uploads of a realistic size: php_value upload_max_filesize "25M" php_value post_max_size "25M" php_value memory_limit "64M" php_value file_uploads "On" * Restart the Apache 2 server sudo /etc/init.d/apache2 restart * Access the MediaWiki configuration utility in a browser using the following URL. Note: Replace localhost with the server hostname: http://localhost/mediawiki/config/index.php * In the MediaWiki configuration, accept the defaults with the following exceptions: ** Wiki Name: site_name (example: "MyWiki") ** Contact e-mail: admin_email (example: "admin@myispdomain.net") ** Database table prefix: prefix (example: "mw_" -- short for MyWiki) * Move the MediaWiki settings file to its run-time directory: sudo mv /var/lib/mediawiki/config/LocalSettings.php /etc/mediawiki * Set the upload directory security to allow uploads: sudo chmod 755 /var/lib/mediawiki/images * Edit the MediaWiki settings file /etc/mediawiki/LocalSettings.php to modify the following variables to permit file uploads of typical types: $wgEnableUploads = true; * Edit the MediaWiki settings file /etc/mediawiki/LocalSettings.php to insert the following variables after the $wgFileExtensions block to override the default and permit uploads of typical mime types: $wgFileExtensions = array( 'png', 'gif', 'jpg', 'jpeg', 'pdf', 'zip' ); $wgMimeTypeBlacklist= array( 'text/html', 'text/javascript', 'text/x-javascript', 'application/x-shellscript', 'application/x-php', 'text/x-php', 'text/x-python', 'text/x-perl', 'text/x-bash', 'text/x-sh', 'text/x-csh', 'application/x-msmetafile', ); * Edit the MediaWiki settings file /etc/mediawiki/LocalSettings.php to insert the following variables before the $wgCacheEpoch block to restrict edit permissions to authenticated users with confirmed e-mail addresses: # Restrict edit permissions to authenticated users with confirmed e-mail $wgGroupPermissions'*''edit' = false; $wgGroupPermissions'user''edit' = false; $wgAutopromote'emailconfirmed' = APCOND_EMAILCONFIRMED; $wgImplicitGroups[] = 'emailconfirmed'; $wgGroupPermissions'emailconfirmed''edit' = true; * Restart the Apache 2 server sudo /etc/init.d/apache2 restart Install and Configure Trac Trac is an open-source wiki-ehanced issue tracking system for software development projects. The following instructions install Trac 0.11.5 and configure it for use with Subversion. * Install the trac package: sudo apt-get install libapache2-mod-python python-setuptools python-subversion sudo easy_install Trac * Create the Trac configuration and environments directories and secure them sudo mkdir /etc/trac sudo mkdir /var/lib/trac sudo chown www-data:www-data /var/lib/trac * Create the Trac project directory and initialize the Trac project. Note: Replace myproject with your project name. sudo mkdir -p /var/lib/trac/myproject sudo trac-admin /var/lib/trac/myproject initenv * In the Creating a new Trac environment... configuration, accept the defaults with the following exceptions: ** Project Name: projectname (example, "My ProjectB") ** Path to repository: svnpath (example, "/var/lib/svn/myproject") * Generate the Trac cgi-bin directory and secure it the project directory. Note: Replace myproject with your project name. sudo trac-admin /var/lib/trac/myproject deploy /tmp/deploy sudo mv /tmp/deploy/* /var/lib/trac sudo chown -R www-data:www-data /var/lib/trac * Create an apache2 configuration file /etc/trac/apache.conf with the following contents: SetHandler mod_python PythonInterpreter main_interpreter PythonHandler trac.web.modpython_frontend PythonOption TracEnvParentDir /var/lib/trac PythonOption TracUriRoot /trac PythonOption PYTHON_EGG_CACHE /tmp # Use Subversion password file for authentication to all # Trac projects AuthType Basic AuthName "trac" AuthUserFile /etc/subversion/passwd Require valid-user * Add the configuration file to the Apache 2 server configuration sudo ln -sn /etc/trac/apache.conf /etc/apache2/conf.d/trac.conf * Reload the Apache 2 server configuration sudo /etc/init.d/apache2 reload * Set up the Trac Web Admin user. Note: Replace myproject with your project name. sudo trac-admin /var/lib/trac/myproject permission add svn TRAC_ADMIN sudo trac-admin /var/lib/trac/myproject permission list svn Backup Configuration Create MySQL Backup User * Connect to MySQL using the root credentials and run the following commands. Note: Replace password with the actual password mysql -u root -p mysql GRANT ALL PRIVILEGES ON *.* TO 'backup'@'localhost' IDENTIFIED BY 'password'; FLUSH PRIVILEGES; Create backup directories * Create and secure the log file directory sudo mkdir /var/log/backup sudo chown www-data:www-data /var/log/backup * Create the backup subdirectories sudo mkdir /var/backup sudo chown www-data:www-data /var/backup sudo mkdir /var/backup/backup sudo chown www-data:www-data /var/backup/backup sudo mkdir /var/backup/svndump sudo chown www-data:www-data /var/backup/svndump sudo mkdir /var/backup/wikidump sudo chown www-data:www-data /var/backup/wikidump sudo mkdir /var/backup/tracdump sudo chown www-data:www-data /var/backup/tracdump Configure backup scripts The attached script archive file contains backup scripts for MediaWiki, Trac and Subversion. * Create the file /var/backup/backupsvn from the file of the same name in the script archive. * Create the file /var/backup/backupmediawiki from the file of the same name in the script archive. * Create the file /var/backup/backuptrac from the file of the same name in the script archive. * Secure the scripts to allow execution by the Apache 2 server user sudo chown www-data:www-data /var/backup/backupsvn sudo chmod u+x /var/backup/backupsvn sudo chown www-data:www-data /var/backup/backupmediawiki sudo chmod u+x /var/backup/backupmediawiki sudo chown www-data:www-data /var/backup/backuptrac sudo chmod u+x /var/backup/backuptrac Schedule backups * Configure the system task scheduler crontab to execute the backup scripts. sudo su www-data - crontab -e * Edit the crontab to add the following lines: #Backup Subversion repositories at 10:00 PM, daily, every day 0 22 * * * (cd /var/backup; ./backupsvn >/var/log/backup/backupsvn.log 2>&1) #Backup MediaWiki database and files at 10:10 PM, daily, every day 10 22 * * * (cd /var/backup; ./backupmediawiki >/var/log/backup/backupmediawiki.log 2>&1) #Backup Trac database and files at 10:20 PM, daily, every day 20 22 * * * (cd /var/backup; ./backuptrac >/var/log/backup/backuptrac.log 2>&1) References * Ubuntu Server Guide * MediaWiki Manual Configuring file uploads * MediaWiki Meta wiki Uploading files (workaround for phpinfo() issue) * MediaWiki Manual Backing up a wiki * Trac Installation Guide * Trac on Ubuntu * Trac Backup